import {
  getMajorList, addMajorList, updateMajorList,
  deleteMajorList, searchMajorList, getStudentList,
  searchStudent, createStudent, updateStudent, deleteStudent,
  getStudyRecordList, addStudyRecord,
  updateStudyRecord, deleteStudyRecord,
  getClassSelectList, getChapterSelectList,
  getUserList, getClassList, addClass,synchronousFace,
  updateClass, delClass, getRulesList,selectAllOfficeFeedback,delFeedback,
  rulesCreateOrUpdate, deleteRules, getDatumList, getIdsFormUser,selectAllSearchToExcel,
  addDatumOrUpdate, delDatum, getChapterList, getPidList, createChapterOrUpdate,deleteChapter
} from "@/api/office"

const state = {
  majorList: null,
  studentList: null,
  studyRecordList: null,
  classList: null,
  rulesList: null,
  datumList: null,
  chapterList: null,
  feedbackList: null,
};
const getters = {
  majorList: (status) => status.majorList,
  studentList: (status) => status.studentList,
  studyRecordList: (status) => status.studyRecordList,
  getClassSelecthList: (status) => status.getClassSelecthList,
  classList: (status) => status.classList,
  rulesList: (status) => status.rulesList,
  datumList: (status) => status.datumList,
  chapterList: (status) => status.chapterList,
  feedbackList: (status) => status.feedbackList,
}
const mutations = {
  setMajorList(state, data) {
    state.majorList = data;
  },
  setFeedbackList(state, data) {
    state.feedbackList = data;
  },
  setStudentList(state, data) {
    state.studentList = data;
  },
  setStudyRecordList(state, data) {
    state.studyRecordList = data;
  },
  setClassList(state, data) {
    state.classList = data;
  },
  setRulesList(state, data) {
    state.rulesList = data;
  },
  setDatumList(state, data) {
    state.datumList = data;
  },
  setChapterList(state, data) {
    state.chapterList = data;
  },
}
const actions = {
  async getMajorList({commit}, param) {
    const {data} = await getMajorList(param);
    commit("setMajorList", data);
  },
  async searchMajorList({commit}, param) {
    const {data} = await searchMajorList(param);
    commit("setMajorList", data);
  },
  async addMajorList({commit}, param) {
    return await addMajorList(param);
  },
  async updateMajorList({commit}, param) {
    return await updateMajorList(param);
  },
  async deleteMajorList({commit}, param) {
    return await deleteMajorList(param);
  },

  async getStudentList({commit}, param) {
    const {data} = await getStudentList(param);
    commit("setStudentList", data);
  },
  async getIdsFormUser({commit}, param) {
    const {data} = await getIdsFormUser(param);
    commit("setStudentList", data);
  },
  async searchStudent({commit}, param) {
    const {data} = await searchStudent(param);
    commit("setStudentList", data);
  },
  async createStudent({commit}, param) {
    return await createStudent(param);
  },
  async updateStudent({commit}, param) {
    return await updateStudent(param);
  },
  async deleteStudent({commit}, param) {
    return await deleteStudent(param);
  },

  async getStudyRecordList({commit}, param) {
    const {data} = await getStudyRecordList(param);
    commit("setStudyRecordList", data);
  },
  async addStudyRecord({commit}, param) {
    return await addStudyRecord(param);
  },
  async updateStudyRecord({commit}, param) {
    return await updateStudyRecord(param);
  },
  async deleteStudyRecord({commit}, param) {
    return await deleteStudyRecord(param);
  },
  async getClassSelectList({commit}, param) {
    return await getClassSelectList(param);
  },

  async getChapterSelectList({commit}, param) {
    return await getChapterSelectList(param);
  },
  async getUserList({commit}, param) {
    return await getUserList(param);
  },
  async getClassList({commit}, param) {
    const {data} = await getClassList(param);
    commit("setClassList", data);
  },
  async addClass({commit}, param) {
    return await addClass(param);
  },
  async updateClass({commit}, param) {
    return await updateClass(param);
  },
  async delClass({commit}, param) {
    return await delClass(param);
  },

  async getRulesList({commit}, param) {
    const {data} = await getRulesList(param);
    commit("setRulesList", data);
  },
  async rulesCreateOrUpdate({commit}, param) {
    return await rulesCreateOrUpdate(param);
  },
  async deleteRules({commit}, param) {
    return await deleteRules(param);
  },

  async getDatumList({commit}, param) {
    const {data} = await getDatumList(param);
    commit("setDatumList", data);
  },
  async addDatumOrUpdate({commit}, param) {
    return await addDatumOrUpdate(param);
  },
  async delDatum({commit}, param) {
    return await delDatum(param);
  },

  async getChapterList({commit}, param) {
    const {data} = await getChapterList(param);
    commit("setChapterList", data);
  },
  async getPidList({commit}, param) {
    return await getPidList(param);
  },
  async createChapterOrUpdate({commit}, param) {
    return await createChapterOrUpdate(param);
  },
  async selectAllSearchToExcel({commit}, param) {
    return await selectAllSearchToExcel(param);
  },
  async deleteChapter({commit}, param) {
    return await deleteChapter(param);
  },

  async selectAllOfficeFeedback({commit}, param) {
    const {data} = await selectAllOfficeFeedback(param);
    commit("setFeedbackList", data);
  },
  async delFeedback({commit}, param) {
    return await delFeedback(param);
  },

  async synchronousFace({commit}, param) {
    return await synchronousFace(param);
  },

}

export default {state, getters, mutations, actions};

